package com.hfh.homework;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

/**
 * @Author hfh
 * @Date 2022 09 14 16 12
 **/
public class LoginClient {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket(InetAddress.getLocalHost(),8888);

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username = sc.next();
        System.out.println("请输入密码：");
        String password = sc.next();
        User user = new User(username,password);

        ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
        oos.writeObject(user);

        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        System.out.println(br.readLine());

        br.close();
        oos.close();
        sc.close();
        s.close();

    }
}